/**
 *  NetLogo Categorical Range  Specification
 *
 * 
 *   @author NetLogo
 */

package model;

import java.util.ArrayList;
import java.util.List;


/** For any parameter that is fixed for the search.
 */
public strictfp class CategoricalSpec extends ParameterSpec {
	private List<Object> choices;
	
	public CategoricalSpec(String name, List<Object> choices) {
		super(name);
		this.choices = choices;
	}
	public CategoricalSpec(String name, Object... choiceArray) {
		super(name);
		this.choices = new ArrayList<Object>();
		for (Object obj : choiceArray)
		{
			this.choices.add( obj );
		}
	}

	@Override
	public long choiceCount()
	{
		return choices.size() ;
	}

	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		sb.append( "[ ");
		sb.append('"');
		sb.append(name);
		sb.append('"');
		for (Object obj: choices)
		{
			sb.append(" ");
			sb.append(obj);
		}
		sb.append(" ]");
		return sb.toString();
	}
	@Override
	public Object getValueFromChoice(long choice, long maxNumChoices) {
		return choices.get((int)(choice % choices.size()));
	}
}
